package com.wpj.common.entity;

import com.sun.org.apache.regexp.internal.RE;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultEntity<T> {

    private static  final String SUCCESS= "SUCCESS";
    private static  final String FALL= "FALL";
    private static  final  String MSG_SUCCESS="操作成功";
    private static  final  String MSG_FALL="操作失败";
    private static  final  String NO_URL=null;

    private String msg; // 错误信息
    private String state; // 状态
    private T data; // 数据
    private String url; // 跳转的路径

    /**
     * 返回失败
     * @param <T>
     * @return
     */
    public static <T> ResultEntity<T> FALL(){
        return new ResultEntity<T>(MSG_FALL,FALL,null,NO_URL);
    }

    /**
     * 返回失败
     * @param msg 失败提示信息
     * @param <T>
     * @return
     */
    public static <T> ResultEntity<T> FALL(String msg){
        return new ResultEntity<T>(msg,FALL,null,NO_URL);
    }

    /**
     * 提示成功,没有返回的数据
     * @param <T>
     * @return
     */
    public static <T> ResultEntity<T> SUCCESS(){
        return new ResultEntity<T>(MSG_SUCCESS,SUCCESS,null,NO_URL);
    }

    /**
     * 成功后跳转到某个url
     * @param url
     * @param <T>
     * @return
     */
    public static <T> ResultEntity<T> SUCCESS(String url){
        return new ResultEntity<T>(MSG_SUCCESS,SUCCESS,null,url);
    }

}
